<?=$this->form?>
<script type="text/javascript">
    $(document).ready(function(){
        $('select#danhmuc1').change(function(){
            var id_dm1=$(this).val();            
            $.ajax({
                type: "POST",
                url: "<?=BASE_URL?>/admin/tintuc/getdanhmuc2/id/"+id_dm1,                    
                //data: id_dm1,                
                dataType: 'json',
                success: function(data) {
                    $('select#danhmuc2 option[value!="-1"]').remove();
                    $('select#danhmuc2').append(new Option('--- Tất cả ---','0'));
                    for(var key in data)
                    {                        
                        $('select#danhmuc2').append(new Option(data[key],key));
                    }                    
                    //alert("AJAX call successful and this data was returned: " + data);                    
                },
                error: function() {
                    $('select#danhmuc2 option[value!="-1"]').remove();
                }
            });
            return false;                       
        });
    });   
</script>

<table class="table blue_table">
	<tr>
        <th style="width:5%;">Mã tin</th>	      
        <th style="width:15%;">Danh mục 1</th>
        <th style="width:15%;">Danh mục 2</th>
        <th style="width:50%;">Tên</th>
        <th style="width:5%;">Hiển thị</th>
        <th style="width:5%;">Sửa</th>
        <th style="width:5%;">Xóa</th>
	</tr>  
          
    <?php
        $dem=0;
        foreach($this->data as $item){
            $dem++;
    ?>
        <tr id="<?=$item[id]?>">
    		<td style="width:5%"><?=$item[stt]?></td>            
    		<td id="danhmuc1_<?=$item['news_cat_id']?>" style="width:15%"><?=$item['news_cat_ten']?></td>
            <td id="danhmuc2_<?=$item['news_item_id']?>" style="width:15%"><?=$item['news_item_ten']?></td>
            <td id="e_ten" style="width:50%"><a href="#" style="text-decoration:none;"><?=$item['ten']?></a></td>            		
            <td style="width:5%">              		
        		<?php
        		if($item['hienthi']==1){
        		?>
                    <a href="#" onclick="showTin(<?=$item[id]?>)"><img src="<?=BASE_URL?>/public/images/active_1.png"/></a>
        		<? 
        		}else{
        		?>
                    <a href="#" onclick="showTin(<?=$item[id]?>)"><img src="<?=BASE_URL?>/public/images/active_0.png"/></a>
                <?php
                }?>        
            </td>                 		
    		<td style="width:5%;"><a href="#" onClick="editTin(<?=$item[id]?>)"><img src="<?=BASE_URL?>/public/images/edit.png"/></a></td>
    		<td style="width:5%;"><a href="#" onClick="delTin('<?=$item[id]?>')"><img src="<?=BASE_URL?>/public/images/delete.png"/></a></td>
    	</tr>
    <?php                       
        }
    ?> 
</table>
    <a href="<?=BASE_URL?>/admin/tintuc/formaddtin"><img src="<?=BASE_URL?>/public/images/add.jpg" border="0"  /></a>
<?php 
       echo $this->paginationControl($this->data, 'Sliding' , 'pagination.phtml'); 
?>


